package leetcode.editor.week.week309;

// 6167. 检查相同字母间的距离
// https://leetcode.cn/problems/check-distances-between-same-letters/
public class Solution6167 {
    public boolean checkDistances(String s, int[] distance) {
        int n = s.length();
        for(int i = 0; i < n; i++) {
            char c = s.charAt(i);
            for(int j = i + 1; j < n; j++) {
                if(s.charAt(j) == c) {
                    if(distance[c - 'a'] != j - i - 1) return false;
                }
            }
        }

        return true;
    }
}
